//index.js
var dateTimePicker = require('../../utils/dateTimePicker.js');
//获取应用实例
const app = getApp();
var imageCount = 10;
var regioncode = [];
var tempTbApplyInfo = {
  injuredName:'',
  injuredIdcard:'',
  injuredSex:'',
  injuredPart: '',
  injuredDate: '',
  injuredPhone: '',
  injuredAddress: '',
  companyName: '',
  companyUsername: '',
  companyUserphone: '',
  companyUsertel: '',
  companyAddress: '',

  identiInjuredNum: '',
  firstIdentiNum: '',
  firstIdnetiDate: '',
  firstIdentiConclusion: '',
  injuredGrade: '',
  applyType: '',
  applySubject: '',
  applyItem: '',
  applyReason: '',
  areacode: '',
  receiveCode: '',
};
var fjlist = '';

Page({
  //事件处理函数
  bindViewTap: function () {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  data: {
    date: '2018-10-01',
    time: '12:00',
    dateTimeArray: null,
    dateTime: null,
    dateTimeArray1: null,
    dateTime1: null,
    startYear: 2000,
    endYear: 2050,
    region: ['0', '0'],
    regionArray: [['请选择','衡水市', '廊坊市', '沧州市', '承德市', '唐山市', '石家庄市', '邯郸市', '秦皇岛市', '邢台市', '张家口市', '保定市', '省本级', '辛集', '定州', '保定市机关事业','石家庄市机关'], ['请选择']],
    hiddenBasic: false,
    hiddenApply: true,
    hiddenUpload: true,
    src: '../../image/bj.png',
    sex: '',
    area: '',
    injuredDate: '',
    appraisalDate: '',
    sexcolor: '#808080',
    regioncolor: '#808080',
    grandcolor: '#808080',
    typecolor: '#808080',
    apply:{},
    applyIndex:0,
    applyList:['请选择','单位申请','个人申请'],
    applyObj: [{},{TYPECODE: '1',TYPENAME: '单位申请'},{TYPECODE: '2',TYPENAME: '个人申请'}],
    sexIndex: 0,
    sexList: ['请选择', '男', '女'],
    sexObj: [{},{TYPECODE: '1',TYPENAME: '男'},{TYPECODE: '2',TYPENAME: '女'}],
    disability:{},
    disabilityIndex: 0,
    disabilityList: ['请选择','未达到等级', '伤残一级', '伤残二级', '伤残三级', '伤残四级', '伤残五级', '伤残六级', '伤残七级', '伤残八级', '伤残九级', '伤残十级', '停工留薪期内死亡', '停工留薪期满后死亡', '失踪', '文革伤残','直接死亡'],
    disabilityObj:[{},
      {TYPECODE: '00',TYPENAME:'未达到等级'},{TYPECODE: '01',TYPENAME: '伤残一级'}, {TYPECODE: '02',TYPENAME: '伤残二级'},
      {TYPECODE: '03',TYPENAME: '伤残三级'}, {TYPECODE: '04',TYPENAME: '伤残四级'}, {TYPECODE: '05',TYPENAME: '伤残五级'},
      {TYPECODE: '06',TYPENAME: '伤残六级'}, {TYPECODE: '07',TYPENAME: '伤残七级'}, {TYPECODE: '08',TYPENAME: '伤残八级'}, 
      {TYPECODE: '09',TYPENAME: '伤残九级'}, {TYPECODE: '10',TYPENAME: '伤残十级'}, {TYPECODE: '11',TYPENAME: '停工留薪期内死亡'}, 
      {TYPECODE: '22',TYPENAME: '停工留薪期满后死亡'}, {TYPECODE: '33',TYPENAME: '失踪'}, {TYPECODE: '41',TYPENAME: '文革伤残'},
      {TYPECODE: '44',TYPENAME: '直接死亡'}], 
    customItem: '请选择',
    uploadImages: [
    { title: '身份证扫描件', name: 'sfzsmj', imageSrc: '', evalList: [{ tempFilePaths: [], imgList: [] }] },
    { title: '工伤认定书', name: 'gsrds', imageSrc: '', evalList: [{ tempFilePaths: [], imgList: [] }]}, 
    { title: '送达回执', name: 'sdhz', imageSrc: '', evalList: [{ tempFilePaths: [], imgList: [] }] }, 
    { title: '初(复)鉴定结论书', name: 'cfjdjls', imageSrc: '', evalList: [{ tempFilePaths: [], imgList: [] }]}, 
    { title: '再鉴申请书', name: 'zjsqs', imageSrc: '', evalList: [{ tempFilePaths: [], imgList: [] }] },
    { title: '再鉴委托书', name: 'zjwts', imageSrc: '', evalList: [{ tempFilePaths: [], imgList: [] }] },
    { title: '被委托人身份证', name: 'bwtrsfz', imageSrc: '', evalList: [{ tempFilePaths: [], imgList: [] }]}]
  },
  changeDate(e) {
    this.setData({ date: e.detail.value });
  },
  changeTime(e) {
    this.setData({ time: e.detail.value });
  },
  changeDateTime(e) {
    this.setData({ dateTime: e.detail.value });
  },
  changeDateTime1(e) {
    var dateTimeArray1 = this.data.dateTimeArray1;
    var dateTime1 = this.data.dateTime1;
    var dateTime = dateTimeArray1[0][dateTime1[0]] + "-" + dateTimeArray1[1][dateTime1[1]] + "-" + dateTimeArray1[2][dateTime1[2]] + " " + dateTimeArray1[3][dateTime1[3]] + ":" + dateTimeArray1[4][dateTime1[4]];
    this.setData({ dateTime1: e.detail.value, injuredDate: dateTime });
  },
  changeDateTimeColumn(e) {
    var arr = this.data.dateTime, dateArr = this.data.dateTimeArray;

    arr[e.detail.column] = e.detail.value;
    dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);

    this.setData({
      dateTimeArray: dateArr,
      dateTime: arr
    });
  },
  changeDateTimeColumn1(e) {
    var arr = this.data.dateTime1, dateArr = this.data.dateTimeArray1;

    arr[e.detail.column] = e.detail.value;
    dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);

    this.setData({
      dateTimeArray1: dateArr,
      dateTime1: arr
    });
  },
  onLoad: function () {
    // 获取完整的年月日 时分秒，以及默认显示的数组
    var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
    var obj1 = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
    // 精确到分的处理，将数组的秒去掉
    var lastArray = obj1.dateTimeArray.pop();
    var lastTime = obj1.dateTime.pop();

    this.setData({
      dateTime: obj.dateTime,
      dateTimeArray: obj.dateTimeArray,
      dateTimeArray1: obj1.dateTimeArray,
      dateTime1: obj1.dateTime
    });
  },
  formSubmit: function (e) {
    console.log('form发生了submit事件，携带数据为：', e.detail.value)
  },

 // 点击行政区划组件
  bindMultiPickerChange: function(e){
    console.log('picker发送选择改变，携带值为', e.detail.value)
    self = this;
    self.setData({
      region: e.detail.value,
    })
    
    if (e.detail.value[0] != 0) {
      self.setData({
        regioncolor: '#000'
      })
    } else {
      self.setData({
        regioncolor: '#808080'
      })
    }
      
    var areaObj = regionArrayObj[e.detail.value[0]][e.detail.value[1]];
    tempTbApplyInfo.areacode = areaObj.code;
    console.log('areaObj',areaObj);
  },
  // 地区选择器列改变事件
  bindMultiPickerColumnChange: function (e){
    console.log('修改的列为', e.detail.column, '，值为', e.detail.value);
    var data = {
      regionArray: this.data.regionArray,
      region: this.data.region
    };
    data.region[e.detail.column] = e.detail.value;
    console.log(data.region);

    switch (e.detail.column) {
      case 0:
        for (var i = 0; i < regionArrayObj.length; i++){
          if(data.region[0]==i){
            var array1 = [];
            console.log('regionArrayObj[i]', regionArrayObj[i])
            for (var j = 0; j < regionArrayObj[i].length; j++){
              array1[j] = regionArrayObj[i][j].value;
            }
            data.regionArray[1] = array1;
          }
        }
      break;
      case 1:{

      }
      break;
    }
    console.log(data.regionArray)
    this.setData({
      regionArray:data.regionArray
    })
  },
  //点击伤残等级组件
  bindDisabilityChange: function (e) {
    self = this;
    self.setData({
      disability: self.data.disabilityObj[e.detail.value],
      disabilityIndex: e.detail.value
    })
    if (e.detail.value != 0) {
      self.setData({
        grandcolor: '#000'
      })
    } else {
      self.setData({
        grandcolor: '#808080'
      })
    }
    console.log('picker发送选择改变，携带值为', self.data.disability)
  },

  //点击在线申请类型组件
  bindApplyChange: function (e) {
    self = this;
    self.setData({
      apply: self.data.applyObj[e.detail.value],
      applyIndex: e.detail.value
    })
    if (e.detail.value != 0) {
      self.setData({
        typecolor: '#000'
      })

      if (e.detail.value == 2){
        var imgNew = self.data.uploadImages;
        imgNew[5].strongcolor = 'black';
        imgNew[6].strongcolor = 'black';
        self.setData({
          uploadImages: imgNew
        })
      }else{
        var imgNew = self.data.uploadImages;
        imgNew[5].strongcolor = 'red';
        imgNew[6].strongcolor = 'red';
        self.setData({
          uploadImages: imgNew
        })
      }
    } else {
      self.setData({
        typecolor: '#808080'
      })
    }
    console.log('picker发送选择改变，携带值为', self.data.apply)
  },

  // 点击职工性别组件
  bindSexChange: function (e) {
    self = this;
    self.setData({
      sex: self.data.sexObj[e.detail.value],
      sexIndex: e.detail.value
    })
    
    if (e.detail.value != 0){
      self.setData({
        sexcolor:'#000'
      })
    }else{
      self.setData({
        sexcolor: '#808080'
      })
    }
    console.log('picker发送选择改变，携带值为', self.data.sex)
  },

  //  点击日期组件确定事件  
  bindDateChange: function (e) {
    console.log(e.detail.value)
    this.setData({
      injuredDate: e.detail.value
    })
  },

  bindAppraisalDateChange: function (e) {
    console.log(e.detail.value)
    this.setData({
      appraisalDate: e.detail.value
    })
  },
  // 选择图片
  joinPicture: function (e) {
    var index = e.currentTarget.dataset.index;
    var idx = e.currentTarget.id;
    var evalList = this.data.uploadImages[idx].evalList;
    var that = this;
    var imgNumber = evalList[index].tempFilePaths;
    if (imgNumber.length >= imageCount) {
      wx.showModal({
        title: '',
        content: '最多上传十张图片',
        showCancel: false,
      })
      return;
    }
    wx.showActionSheet({
      itemList: ["从相册中选择", "拍照"],
      success: function (res) {
        if (!res.cancel) {
          if (res.tapIndex == 0) {
            that.chooseWxImage("album", imgNumber,idx);
          } else if (res.tapIndex == 1) {
            that.chooseWxImage("camera", imgNumber,idx);
          }
        }
      }
    })
  },
  chooseWxImage: function (type, list, idx) {
    var img = list;
    var len = img.length;
    var that = this;
    var evalList = this.data.uploadImages[idx].evalList;
    wx.chooseImage({
      count: 9,
      sizeType: ["original", "compressed"],
      sourceType: [type],
      success: function (res) {
        var addImg = res.tempFilePaths;
        var addLen = addImg.length;
        if ((len + addLen) > imageCount) {
          for (var i = 0; i < (addLen - len); i++) {
            var str = {};
            str.pic = addImg[i];
            img.push(str);
          }
        } else {
          for (var j = 0; j < addLen; j++) {
            var str = {};
            str.pic = addImg[j];
            img.push(str);
          }
        }

        // that.data.uploadImages[idx].evalList = evalList;
        // var uploadImgNew = that.data.uploadImages;
        // that.setData({ uploadImages: uploadImgNew });
        that.upLoadImg(img, idx);
      },
    })
  },
  //多张图片上传
  upLoadImg: function (path, idx) {
    var that = this;
    var curImgList = [];
    for (var i = 0; i < path.length; i++) {
      wx.showToast({
        icon: "loading",
        title: "正在上传"
      }),
        wx.uploadFile({
          // url:'https://14592619.qcloud.la/upload',
          url:'http://110.249.254.141:10010/ljpt-repeat/file.do?tempUploadFile',
          filePath: path[i].pic,
          name: 'file',
          header: { "Content-Type": "multipart/form-data" },
          formData: {
            douploadpic: '1'
          },
          success: function (res) {
            var dataWWarp = res.data.substr(1, res.data.length - 2).replace(/\\"/g, '"');
            var jsonres = JSON.parse(dataWWarp);
            if (jsonres.code == '0') {
              curImgList.push(jsonres.relativelyPath);
              console.log('res.data', res.data);
              var evalList = that.data.uploadImages[idx].evalList;
              evalList[0].imgList = curImgList;
              that.data.uploadImages[idx].evalList = evalList;
              var imagesNew = that.data.uploadImages;
              that.setData({
                uploadImages: imagesNew
              })

              console.log('uploadImages', imagesNew); 
            } else {
              wx.showModal({
                title: '提示',
                content: '上传失败',
                showCancel: false
              })
              return;
            }
          },
          fail: function (e) {
            wx.showModal({
              title: '提示',
              content: '上传失败',
              showCancel: false
            })
          },
          complete: function () {
            wx.hideToast();  //隐藏Toast
          }
        })
    }
  },
  //删除图片
  clearImg: function (e) {
    var index = e.currentTarget.dataset.index;
    var idx = e.currentTarget.id;
    var evalList = this.data.uploadImages[idx].evalList;
    var img = evalList[0].tempFilePaths;
    img.splice(index, 1); 
    this.data.uploadImages[idx].evalList[0].tempFilePaths = img;
    var imagesNew = this.data.uploadImages; 
    this.setData({
      uploadImages: imagesNew
    });
    // this.upLoadImg(img, idx);
  },
// 上传图片
  chooseImage: function (e) {
    var self = this;
   var uploadFileUrl = 'https://14592619.qcloud.la/upload';
    // var uploadFileUrl = 'http://110.249.254.141:10010/ljpt-repeat/file.do?tempUploadFile';
    var idx = e.currentTarget.id;
    wx.chooseImage({
      count: 1,
      sizeType: ['compressed'],
      sourceType: ['album'],
      success: function (res) {
        console.log('chooseImage success, temp path is', res.tempFilePaths[0])
 
        var imageSrc = res.tempFilePaths[0]
        
        wx.uploadFile({
          url: uploadFileUrl,
          filePath: imageSrc,
          name: 'file',
          header : {
            'content-type': 'application/json'
          },
          success: function (res) {
            console.log('uploadImage success, res is:', res)
            var dataWWarp = res.data.substr(1, res.data.length - 2).replace(/\\"/g,'"');
            console.log('dataWWarp:', dataWWarp);

            var jsonres = JSON.parse(dataWWarp);
            console.log('jsonres:', jsonres.code);
            console.log('jsonres:', jsonres.relativelyPath);

            if (jsonres.code == '0'){
              self.data.uploadImages[idx].imageSrc = jsonres.relativelyPath;
              var uploadImgNew = self.data.uploadImages;
              self.setData({ uploadImages: uploadImgNew });
              console.log('uploadImgNew', self.data.uploadImages);
            }else{
              wx.showToast({ title: '上传图片失败', icon: 'none', duration: 2000 })
            }
          },
          fail: function ({ errMsg }) {
            console.log('uploadImage fail, errMsg is', errMsg)
          }
        })
      },
      fail: function ({ errMsg }) {
        console.log('chooseImage fail, err is', errMsg)
      }
    })
  },
  
  basicDataSubmit: function (e){
    if (checkBasicData(e.detail.value)) {
      this.setData({ hiddenBasic: true, hiddenApply: false, hiddenUpload: true });
    }
  },

  applyDataSubmit: function (e) {
    if (checkApplyData(e.detail.value)) {
      this.setData({ hiddenBasic: true, hiddenApply: true, hiddenUpload: false });
      console.log("tempTbApplyInfo:", tempTbApplyInfo);
    }
  },
  changeTab: function (event) {
    if (event.currentTarget.id == 'basicTab') {
      this.setData({
        hiddenBasic: false,
        hiddenApply: true,
        hiddenUpload: true
      });
    } else if (event.currentTarget.id == 'applyTab') {
      this.setData({
        hiddenBasic: true,
        hiddenApply: false,
        hiddenUpload: true
      });
    } else {
      this.setData({
        hiddenBasic: true,
        hiddenApply: true,
        hiddenUpload: false
      });
    }
  },
  submitForm: function (e) {
    
    var self = this;
    console.log('tempTbApplyInfo',tempTbApplyInfo);
    console.log('uploadImages', self.data.uploadImages);
    if (checkUploadImgData(self.data.uploadImages)){
      wx.request({
        url: 'http://127.0.0.1/ljpt-repeat/tbApplyInfoController.do?tempDoAdd',
        //url: 'http://110.249.254.141:10010/ljpt-repeat/tbApplyInfoController.do?tempDoAdd',
        // url: 'http://192.168.3.112/pet/mag/login',
        method: 'POST',
        data: {
          injuredName: tempTbApplyInfo.injuredName,
          injuredIdcard: tempTbApplyInfo.injuredIdcard,
          injuredSex: tempTbApplyInfo.injuredSex,
          injuredPart: tempTbApplyInfo.injuredPart ,
          injuredDate: tempTbApplyInfo.injuredDate,
          injuredPhone: tempTbApplyInfo.injuredPhone,
          injuredAddress: tempTbApplyInfo.injuredAddress,
          companyName: tempTbApplyInfo.companyName,
          companyUsername: tempTbApplyInfo.companyUsername,
          companyUserphone: tempTbApplyInfo.companyUserphone,
          companyUsertel: tempTbApplyInfo.companyUsertel,
          companyAddress: tempTbApplyInfo.companyAddress,
          identiInjuredNum: tempTbApplyInfo.identiInjuredNum,
          firstIdentiNum: tempTbApplyInfo.firstIdentiNum,
          firstIdnetiDate: tempTbApplyInfo.firstIdnetiDate,
          firstIdentiConclusion: tempTbApplyInfo.firstIdentiConclusion,
          injuredGrade: tempTbApplyInfo.injuredGrade,
          applyType: tempTbApplyInfo.applyType,
          applySubject: tempTbApplyInfo.applySubject,
          applyItem: tempTbApplyInfo.applyItem,
          applyReason: tempTbApplyInfo.applyReason,
          areacode: tempTbApplyInfo.areacode,

          fjlist: fjlist
        },
        header: {
          'content-type': 'application/x-www-form-urlencoded' // 默认值
        },
        success: function (res) {
          console.log(res.data);
          if(res.data.success){
            console.log(res.data.msg);
            if ('再鉴申请添加成功' == res.data.msg){
              wx.navigateTo({
                url:'./success/success'
              })
            }else{
              wx.showToast({ title: res.data.msg, icon: 'none', duration: 1000 })
            }
          }
        },
      }) 
    }
  },

  //界面显示监听
  onShow: function(){
    var self = this;
    wx.getStorage({
      key: 'apply_items_selected',
      success: function(res) {
        var items = res.data;
        self.setData({
          applyItem: res.data,
        })
      },
    });
    wx.getStorage({
      key: 'apply_subject_selected',
      success: function (res) {
        var items = res.data;
        self.setData({
          applySubject: res.data,
        })
      },
    });
    wx.getStorage({
      key: 'apply_items_code',
      success: function(res) {
        tempTbApplyInfo.applyItem = res.data;
      },
    });
    wx.getStorage({
      key: 'apply_subject_code',
      success: function(res) {
        tempTbApplyInfo.applySubject = res.data;
      },
    });
  }
})

function checkBasicData(data){
  console.log(data);
  if (data.userName == '') {
    wx.showToast({title: '职工姓名不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.sex == null) {
    wx.showToast({ title: '职工性别不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.idCard == '') {
    wx.showToast({ title: '职工身份证不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  var regIdNo = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
  if (!regIdNo.test(data.idCard)) {
    wx.showToast({ title: '身份证号填写有误', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.injuredPhone == '') {
    wx.showToast({ title: '职工联系电话不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
  if (!myreg.test(data.injuredPhone)) {
    wx.showToast({ title: '职工联系电话填写有误', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.injuredAddress == '') {
    wx.showToast({ title: '职工住址不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.companyName == '') {
    wx.showToast({ title: '单位名称不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.companyUsername == '') {
    wx.showToast({ title: '单位联系人不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.companyUserphone == '') {
    wx.showToast({ title: '单位联系人手机号不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (!myreg.test(data.companyUserphone)) {
    wx.showToast({ title: '单位联系人手机号填写有误', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.companyUsertel == '') {
    wx.showToast({ title: '单位联系人电话不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.companyAddress == '') {
    wx.showToast({ title: '单位地址不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  tempTbApplyInfo.injuredName = data.userName;
  tempTbApplyInfo.injuredIdcard = data.idCard;
  tempTbApplyInfo.injuredSex = data.sex;
  tempTbApplyInfo.injuredPhone = data.injuredPhone;
  tempTbApplyInfo.injuredDate = data.sex;
  tempTbApplyInfo.injuredAddress = data.injuredAddress;
  tempTbApplyInfo.companyName = data.companyName;
  tempTbApplyInfo.companyUsername = data.companyUsername;
  tempTbApplyInfo.companyUserphone = data.companyUserphone;
  tempTbApplyInfo.companyUsertel = data.companyUsertel;
  tempTbApplyInfo.companyAddress = data.companyAddress;
  return true;
} 

function checkApplyData(data) {
  console.log(data);
  if (data.identiInjuredNum == '') {
    wx.showToast({ title: '工伤认定书编号不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  
  if (tempTbApplyInfo.areacode == '') {
    wx.showToast({ title: '行政区划不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.injuredDate == '') {
    wx.showToast({ title: '受伤时间不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.injuredPart == '') {
    wx.showToast({ title: '受伤部位不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.firstIdentiNum == '') {
    wx.showToast({ title: '初鉴结论编号不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.firstIdnetiDate == '') {
    wx.showToast({ title: '初鉴结论日期不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.injuredGrade == null) {
    wx.showToast({ title: '伤残等级不能为空', icon: 'none', duration: 1000 })
    return false;
  } 
  if (data.firstIdentiConclusion == '') {
    wx.showToast({ title: '初鉴结论不能为空', icon: 'none', duration: 1000 })
    return false;
  } 
  if (data.applyType == null) {
    wx.showToast({ title: '再鉴申请类型不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.applyItem == '') {
    wx.showToast({ title: '申请事项不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.applySubject == '') {
    wx.showToast({ title: '申请科目不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  if (data.applyReason == '') {
    wx.showToast({ title: '申请理由不能为空', icon: 'none', duration: 1000 })
    return false;
  }
  tempTbApplyInfo.identiInjuredNum = data.identiInjuredNum;
  tempTbApplyInfo.injuredDate = data.injuredDate;
  tempTbApplyInfo.injuredPart = data.injuredPart;
  tempTbApplyInfo.firstIdentiNum = data.firstIdentiNum;
  tempTbApplyInfo.firstIdnetiDate = data.firstIdnetiDate;
  tempTbApplyInfo.injuredGrade = data.injuredGrade;
  tempTbApplyInfo.firstIdentiConclusion = data.firstIdentiConclusion;
  tempTbApplyInfo.applyType = data.applyType;
  tempTbApplyInfo.applyReason = data.applyReason;
  return true;
}

function checkUploadImgData(data) {
  var tempfjlist = '';
  var len = data.length;
  if (tempTbApplyInfo.applyType == 2){
    len -=2;
  }
  for (var i = 0; i < data.length;i++)
  {
    if (i < len){
      if (data[i].evalList[0].imgList == '') {
        wx.showToast({ title: data[i].title + '不能为空', icon: 'none', duration: 1000 })
        return false;
      }
    }
  
    for (var j = 0; j < data[i].evalList[0].imgList.length;j++){
      tempfjlist += data[i].evalList[0].imgList[j] + ',';
    }
    
    if (i < data.length - 1) tempfjlist += '*^@!';
  }
  fjlist = tempfjlist;
  console.log('fjlist', fjlist);
  return true;
}

var regionArrayObj = [
  [{ value: '请选择', code: '' }],
  [{ value: '深州市', code: '131182' }, { value: '阜城县', code: '131128' }, { value: '故城县', code: '131126' }, { value: '饶阳县', code: '131124' }, { value: '武邑县', code: '131122' }, { value: '衡水市桃城区', code: '131102' }, { value: '冀州市', code: '131181' }, { value: '景县', code: '131127' }, { value: '安平县', code: '131125' }, { value: '武强县', code: '131123' }, { value: '枣强县', code: '131121' }, { value: '衡水市市本级', code: '131101' }, { value: '衡水市开发区', code: '131103' }],

  [{ value: '三河市', code: '131082' }, { value: '大厂回族自治县', code: '131028' }, { value: '大城县', code: '131025' }, { value: '永清县', code: '131023' }, { value: '廊坊市广阳区', code: '131003' }, { value: '廊坊市市本级', code: '131001' }, { value: '霸州市', code: '131081' }, { value: '文安县', code: '131026' }, { value: '香河县', code: '131024' }, { value: '固安县', code: '131022' }, { value: '廊坊市安次区', code: '131002' }, { value: '廊坊市开发区', code: '131040' }],

  [{ value: '黄骅市', code: '130983' }, { value: '泊头市', code: '130981' }, { value: '献县', code: '130929' }, { value: '吴桥县', code: '130928' }, { value: '肃宁县', code: '130926' }, { value: '海兴县', code: '130924' }, { value: '青县', code: '130922' }, { value: '沧州市运河区', code: '130903' }, { value: '沧州市市本级', code: '130901' }, { value: '河间市', code: '130984' }, { value: '任丘市', code: '130982' }, { value: '孟村回族自治县', code: '130930' }, { value: '南皮县', code: '130927' }, { value: '盐山县', code: '130925' }, { value: '东光县', code: '130923' }, { value: '沧县', code: '130921' }, { value: '沧州市新华区', code: '130902' }, { value: '沧州市黄骅港开发区', code: '130940' }, { value: '沧州市中捷高新技术产业开发区', code: '130941' }, { value: '沧州市南大港管理区', code: '130942' }, { value: '沧州市临港经济技术开发区', code: '130945' }],

  [{ value: '宽城满族自治县', code: '130827' }, { value: '丰宁满族自治县', code: '130826' }, { value: '兴隆县', code: '130822' }, { value: '承德市鹰手营子矿区', code: '130804' }, { value: '承德市双桥区', code: '130802' }, { value: '围场满族蒙古族自治县', code: '130828' }, { value: '隆化县', code: '130825' }, { value: '平泉县', code: '130823' }, { value: '承德县', code: '130821' }, { value: '承德市双滦区', code: '130803' }, { value: '承德市市本级', code: '130801' }, { value: '滦平县', code: '130824' }],

  [{ value: '迁西县', code: '130227' }, { value: '滦南县', code: '130224' }, { value: '唐山市丰润区', code: '130208' }, { value: '唐山市开平区', code: '130205' }, { value: '唐山市路北区', code: '130203' }, { value: '唐山市市本级', code: '130201' }, { value: '迁安市', code: '130283' }, { value: '唐山市曹妃甸区', code: '130230' }, { value: '乐亭县', code: '130225' }, { value: '滦县', code: '130223' }, { value: '唐山市丰南区', code: '130207' }, { value: '唐山市路南区', code: '130202' }, { value: '遵化市', code: '130281' }, { value: '玉田县', code: '130229' }, { value: '唐山市古冶区', code: '130204' }, { value: '唐山市海港开发区', code: '130242' }, { value: '唐山市芦台经济技术开发区', code: '130243' }, { value: '唐山市汉沽管理区', code: '130244' }, { value: '唐山市高新技术开发区', code: '130240' }, { value: '唐山市南堡开发区', code: '130241' }], 

  [{ value: '新乐市', code: '130184' }, { value: '石家庄市藁城区', code: '130182' }, { value: '赵县', code: '130133' },
    { value: '平山县', code: '130131' }, { value: '赞皇县', code: '130129' }, { value: '高邑县', code: '130127' },
    { value: '行唐县', code: '130125' }, { value: '正定县', code: '130123' }, { value: '石家庄市裕华区', code: '130108' },
    { value: '石家庄市新华区', code: '130105' }, { value: '石家庄市桥东区', code: '130103' }, { value: '石家庄市市本级', code: '130101' },
    { value: '石家庄市鹿泉区', code: '130185' }, { value: '晋州市', code: '130183' }, { value: '无极县', code: '130130' }, { value: '深泽县', code: '130128' },
    { value: '灵寿县', code: '130126' }, { value: '井陉县', code: '130121' }, { value: '石家庄市井陉矿区', code: '130107' },
    { value: '石家庄市桥西区', code: '130104' }, { value: '石家庄市长安区', code: '130102' }, { value: '元氏县', code: '130132' },
    { value: '石家庄市栾城区', code: '130124' }, { value: '石家庄市开发区', code: '130140' }, { value: '石家庄市正定新区', code: '130141' }, { value: '石家庄市循环化工园区', code: '130142' }, { value: '综合保税区', code: '130143' }], 

  [{ value: '武安市', code: '130481' }, { value: '曲周县', code: '130435' }, { value: '魏县', code: '130434' },
    { value: '广平县', code: '130432' }, { value: '鸡泽县', code: '130431' }, { value: '邱县', code: '130430' },
    { value: '邯郸市永年区', code: '130429' }, { value: '磁县', code: '130427' }, { value: '涉县', code: '130426' },
    { value: '大名县', code: '130425' }, { value: '临漳县', code: '130423' }, { value: '邯郸县', code: '130421' },
    { value: '邯郸市峰峰矿区', code: '130406' }, { value: '邯郸市复兴区', code: '130404' }, { value: '邯郸市邯山区', code: '130402' },
    { value: '邯郸市市本级', code: '130401' }, { value: '馆陶县', code: '130433' }, { value: '邯郸市肥乡区', code: '130428' },
    { value: '成安县', code: '130424' }, { value: '邯郸市丛台区', code: '130403' }, { value: '邯郸市开发区', code: '130440' }
    , { value: '马头生态工业城', code: '130441' }], 

  [{ value: '卢龙县', code: '130324' }, { value: '昌黎县', code: '130322' }, { value: '青龙满族自治县', code: '130321' }, { value: '秦皇岛市北戴河区', code: '130304' }, { value: '秦皇岛市海港区', code: '130302' }, { value: '秦皇岛市市本级', code: '130301' }, { value: '抚宁县', code: '130323' }, { value: '秦皇岛市山海关区', code: '130303' }, { value: '秦皇岛市北戴河新区', code: '130341' }], 

  [{ value: '南宫市', code: '130581' }, { value: '清河县', code: '130534' }, { value: '广宗县', code: '130531' },
    { value: '巨鹿县', code: '130529' }, { value: '南和县', code: '130527' }, { value: '隆尧县', code: '130525' },
    { value: '内丘县', code: '130523' }, { value: '邢台县', code: '130521' }, { value: '邢台市桥东区', code: '130502' },
    { value: '邢台市市本级', code: '130501' }, { value: '沙河市', code: '130582' }, { value: '临西县', code: '130535' },
    { value: '威县', code: '130533' }, { value: '平乡县', code: '130532' }, { value: '新河县', code: '130530' },
    { value: '宁晋县', code: '130528' }, { value: '任县', code: '130526' }, { value: '柏乡县', code: '130524' },
    { value: '临城县', code: '130522' }, { value: '邢台市桥西区', code: '130503' }, { value: '邢台市开发区', code: '130540' }, { value: '大曹庄', code: '130541' }], 

  [{ value: '涿鹿县', code: '130731' }, { value: '张家口市万全区', code: '130729' }, { value: '阳原县', code: '130727' },
    { value: '康保县', code: '130723' }, { value: '宣化县', code: '130721' }, { value: '张家口市宣化区', code: '130705' },
    { value: '张家口市桥东区', code: '130702' }, { value: '赤城县', code: '130732' }, { value: '怀来县', code: '130730' },
    { value: '怀安县', code: '130728' }, { value: '蔚县', code: '130726' }, { value: '沽源县', code: '130724' },
    { value: '张北县', code: '130722' }, { value: '张家口市下花园区', code: '130706' }, { value: '张家口市桥西区', code: '130703' },
    { value: '张家口市市本级', code: '130701' }, { value: '张家口市崇礼区', code: '130733' }, { value: '尚义县', code: '130725' },
    { value: '张家口市察北管理区', code: '130741' }, { value: '张家口市塞北管理区', code: '130742' }, { value: '张家口市高新区', code: '130740' },], 

  [{ value: '高碑店市', code: '130684' },  { value: '雄县', code: '130638' },
    { value: '顺平县', code: '130636' }, { value: '安新县', code: '130632' }, { value: '涞源县', code: '130630' },
    { value: '高阳县', code: '130628' }, { value: '保定市徐水区', code: '130625' }, { value: '保定市满城区', code: '130621' },
    { value: '保定市市本级', code: '130601' }, { value: '望都县', code: '130631' }, { value: '安国市', code: '130683' },
    { value: '涿州市', code: '130681' }, { value: '博野县', code: '130637' }, { value: '蠡县', code: '130635' },
    { value: '易县', code: '130633' }, { value: '容城县', code: '130629' }, { value: '唐县', code: '130627' },
    { value: '定兴县', code: '130626' }, { value: '阜平县', code: '130624' }, { value: '保定市清苑区', code: '130622' },
    { value: '保定市竞秀区', code: '130602' }, { value: '曲阳县', code: '130634' }, { value: '涞水县', code: '130623' },
    { value: '白沟', code: '130640' }, { value: '保定市高新区', code: '130641' }, { value: '保定市莲池区', code: '130606' }], 

  [{ value: '省本级', code: '139901' },], 

  [{ value: '辛集市', code: '130181' },], 

  [{ value: '定州市', code: '130682' },],

  [{ value: '高碑店市机关事业', code: '132684' }, { value: '雄县机关事业', code: '132638' }, { value: '顺平县机关事业', code: '132636' },
    { value: '安新县机关事业', code: '132632' }, { value: '涞源县机关事业', code: '132630' }, { value: '高阳县机关事业', code: '132628' },
    { value: '保定市徐水区机关事业', code: '132625' }, { value: '保定市满城区机关事业', code: '132621' }, { value: '保定市市本级机关事业', code: '132601' },
    { value: '望都县机关事业', code: '132631' }, { value: '安国市机关事业', code: '132683' }, { value: '涿州市机关事业', code: '132681' },
    { value: '博野县机关事业', code: '132637' }, { value: '蠡县机关事业', code: '132635' }, { value: '易县机关事业', code: '132633' },
    { value: '容城县机关事业', code: '132629' }, { value: '唐县机关事业', code: '132627' }, { value: '定兴县机关事业', code: '132626' },
    { value: '阜平县机关事业', code: '132624' }, { value: '保定市清苑区机关事业', code: '132622' }, { value: '保定市竞秀区机关事业', code: '132602' },
    { value: '曲阳县机关事业', code: '132634' }, { value: '涞水县机关事业', code: '132623' }, { value: '白沟机关事业', code: '132640' },
    { value: '保定市高新区机关事业', code: '132641' }, { value: '保定市莲池区机关事业', code: '132606' },],
  
  [{ value: '新乐市', code: '132184' }, { value: '石家庄市藁城区', code: '132182' }, { value: '赵县', code: '132133' },
    { value: '平山县', code: '132131' }, { value: '赞皇县', code: '132129' }, { value: '高邑县', code: '132127' },
    { value: '行唐县', code: '132125' }, { value: '正定县', code: '132123' }, { value: '石家庄市裕华区', code: '132108' },
    { value: '石家庄市新华区', code: '132105' }, { value: '石家庄市桥东区', code: '132103' }, { value: '石家庄市市本级', code: '132101' },
    { value: '石家庄市鹿泉区', code: '132185' }, { value: '晋州市', code: '132183' }, { value: '无极县', code: '132130' },
    { value: '深泽县', code: '132128' }, { value: '灵寿县', code: '132126' }, { value: '井陉县', code: '132121' },
    { value: '石家庄市井陉矿区', code: '132107' }, { value: '石家庄市桥西区', code: '132104' }, { value: '石家庄市长安区', code: '132102' },
    { value: '元氏县', code: '132132' }, { value: '石家庄市栾城区', code: '132124' }, { value: '石家庄市开发区', code: '132140' },
    { value: '石家庄市正定新区', code: '132141' }, { value: '石家庄市循环化工园区', code: '132142' }, { value: '空港工业园', code: '132143' },]
]

